//
//  RHDeviceInfoListCell.m
//  RuiHeAppApp
//
//  Created by Yan Chen on 2023/12/5.
//

#import "RHDeviceInfoListCell.h"
#import "RHDevInfoModel.h"

@interface RHDeviceInfoListCell()
@property (nonatomic, strong) UIImageView *icon;

@property (nonatomic, strong) QMUILabel *titleLab;
@end
@implementation RHDeviceInfoListCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        [self setupUI];
    }
    return self;
}

-(void)setInfoModel:(RHDevInfoModel *)infoModel
{
    _infoModel = infoModel;
    self.titleLab.text = infoModel.sectionTitle.rh_localized;
    self.icon.image = [UIImage imageNamed:infoModel.typeIcon];
}

- (void)setupUI{
    kWeakSelf;
    [self setBackgroundColor:CFTabViewBgColor];
    [self.contentView setBackgroundColor:CFTabViewBgColor];
    
    UIView *bgView = [[UIView alloc] init];
    [bgView rounded:8 width:1 color:kBorderColor];
    [bgView setBackgroundColor:UIColor.whiteColor];
    [self.contentView addSubview:bgView];
    
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.insets(UIEdgeInsetsMake(5,15, 5, 15));
    }];
    
    _icon = [[UIImageView alloc] init];
    [bgView addSubview:_icon];
    [_icon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.equalTo(@(CGSizeMake(25, 25)));
        make.top.mas_offset(15);
        make.left.mas_offset(15);
        make.bottom.mas_offset(-15);
    }];
    
   
    
    _titleLab = [[QMUILabel alloc] init];
    [_titleLab setTextAlignment:NSTextAlignmentLeft];
    [_titleLab setFont:[UIFont systemFontOfSize:14]];
    [_titleLab setTextColor:kCOLOR_HEX(@"3F4443")];
    [bgView addSubview:_titleLab];
    [_titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.icon.mas_right).offset(15);
        make.centerY.equalTo(weakSelf.icon);
    }];
    
    
    UIImageView *arrowImg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"arrow"]];
    [bgView addSubview:arrowImg];
    [arrowImg   mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.equalTo(@(CGSizeMake(20, 20)));
        make.centerY.mas_offset(0);
        make.right.mas_offset(-15);
    }];
}

@end
